
import axios from 'axios';
const service = axios.create({
  baseURL: 'https://api.dg.feibo.com', // api 的 base_url
  timeout: 50000, // 请求超时时间
  headers: {
    'Content-Type': 'application/json'
  },
  transformRequest: [(data, headers) => {
    if (headers['Content-Type'] === 'multipart/form-data') return data;
    return typeof data === 'string' ? data : JSON.stringify(data);
  }] // 参数转换NODE_ENV
});

service.interceptors.request.use(config => {
  return config;
}, error => {
  Promise.reject(error);
});

service.interceptors.response.use(response => {
  return response.data;
}, error => {
  console.error('Respone ' + error);
  if (error.message === 'Network Error') {
    return Promise.reject({ message: '网络错误！请检查网络状态...' });
  }
  return Promise.reject(error);
});
export function getDrawData(data) {
  return service({
    url: '/room/getAllDraw',
    method: 'get',
    params: data
  });
}
export function deleteImg(data) {
  return service({
    url: '/room/deleteDraw',
    method: 'delete',
    data: data
  });
}

export default service;
